import { MenuVO, Menu, getMenuListResultModel } from './model/menuModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
	List = '/sys/menu/list',
	Save = '/sys/menu/save',
	Del = '/sys/menu',
	CheckChild = '/sys/menu/check-child',
	GetMenuList = '/sys/menu/tree'
}

// 菜单树
export const menuList = (params?: MenuVO) => defHttp.post({ url: Api.List, params });

// 保存
export const menuSave = (params: Menu) => defHttp.post<Menu>({ url: Api.Save, params });

// 删除
export const menuDel = (params: { ids: String }) => defHttp.delete<boolean>({ url: Api.Del + `/${params.ids}` });

// 是否包含子菜单
export const menuCheckChild = (params?: { id: String }) => defHttp.get({ url: Api.CheckChild, params });

export const getMenuList = () => {
	return defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList });
};
